package com.turnengine.client.global.game.command;

import com.javabi.command.IExecutableCommand;
import com.javabi.command.IExecutableCommandResponse;
import com.javabi.command.serializer.AbstractCommandDataSerializer;
import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import com.turnengine.client.global.game.bean.GameSerializer;
import com.turnengine.client.global.game.bean.IGame;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * The Get Games Data Serializer.
 */
public class GetGamesDataSerializer extends AbstractCommandDataSerializer<List<IGame>> implements IGetGamesDataSerializer {

	/**
	 * Creates a new Get Games Data Serializer.
	 */
	public GetGamesDataSerializer() {
		super(GetGames.COMMAND_ID);
	}

	@Override
	public List<IGame> readReturnValue(IDataReader reader) throws IOException {
		List<IGame> value = reader.readObjectCollection(new ArrayList<IGame>(), true, false, new GameSerializer());
		return value;
	}

	@Override
	public void writeReturnValue(IDataWriter writer, List<IGame> value) throws IOException {
		writer.writeObjectCollection(value, true, false, new GameSerializer());
	}

	@Override
	public IExecutableCommand<List<IGame>> readRequest(IDataReader reader) throws IOException {

		// Read fields

		// Create object
		GetGames object = new GetGames();
		return object;
	}

	@Override
	public void writeRequest(IDataWriter writer, IExecutableCommand<List<IGame>> argument) throws IOException {
		GetGames object = (GetGames) argument;

		// Get fields

		// Write fields
	}

	@Override
	public IExecutableCommandResponse<List<IGame>> newResponse() {
		return new GetGamesResponse();
	}
}
